{% extends 'base.html' %}

{% block header_js %}
    <title>platform-classification</title>
  <!-- Google Font: Source Sans Pro -->
  <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,400i,700&display=fallback">
  <!-- Font Awesome -->
  <link rel="stylesheet" href="/static/plugins/fontawesome-free/css/all.min.css">
  <!-- DataTables -->
  <link rel="stylesheet" href="/static/plugins/datatables-bs4/css/dataTables.bootstrap4.min.css">
  <link rel="stylesheet" href="/static/plugins/datatables-responsive/css/responsive.bootstrap4.min.css">
  <link rel="stylesheet" href="/static/plugins/datatables-buttons/css/buttons.bootstrap4.min.css">
      <!-- Select2 -->
  <link rel="stylesheet" href="/static/plugins/select2/css/select2.min.css">
  <!-- Theme style -->
  <link rel="stylesheet" href="/static/dist/css/adminlte.min.css">
{% endblock %}

{% block navname %}configuration{% endblock %}
{% block navSon %}configuration{% endblock %}

{% block content %}
     <div class="content-wrapper" style="margin-left: 0px;">
        <section class="content">
          <div class="container-fluid">
            <div class="row">
              <div class="col-12">
                <div class="card">
                  <!-- /.card-header -->
                  <div class="card-body">
                      <div class="form-group" style="margin-top: 30px; margin-bottom: 30px; margin-left: 0px;">
                          <label class="col-sm-12 control-label"><b style="font-size:20px;text-align: right;">配置管理</b></label>
                      </div>
                        <form id="configurationForm" class="form-horizontal col-sm-12" method="post" onsubmit="" style="">
                            {% csrf_token %}
                            <div class="box-body" style="text-align: center">
                                <div class="row">
                                    <div class="col-md-7">
                                        <div class="form-group row" style="text-align: center; font-size:15px;">
                                            <label class="col-sm-2 col-form-label">添加行业</label>
                                            <div class="col-sm-4" style="text-align: center">
                                              <input type="text" class="form-control" id="industry_add" name="industry_add" placeholder="请输入要添加的行业">
                                            </div>
                                        </div>
                                        <div class="form-group row" style="text-align: center; font-size:15px;">
                                            <label class="col-sm-2 col-form-label">删除行业</label>
                                            <div class="col-sm-4" style="text-align: center">
                                              <select class="form-control select2" name="industry_delete" id="industry_delete" data-placeholder='选择行业' style="width: 100%;">
                                                    <option value="" selected disabled>选择要删除的行业</option>
                                                    {% for industry in industry_list %}
                                                        <option value="{{ industry }}">{{ industry }}</option>
                                                    {% endfor %}
                                                </select>
                                            </div>
                                        </div>
                                        <div class="modal-footer" style="width:100%;display: inline-block;float: left;">
                                            <button type="submit" id="submit" class="btn btn-primary" style="width: 20%;display: inline-block;float: left;margin-left: 30px;">
                                                <i class="fas fa-save"></i>
                                                <span>保存</span>
                                            </button>
                                            <button class="btn btn-default" type="button" id="reset" data-dismiss="modal" style="margin-left: 30px; width: 20%;display: inline-block;float: left;">
                                                <i class="fas fa-undo"></i>
                                                <span>重置输入</span>
                                            </button>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </form>
                  </div>
                  <!-- /.card-body -->
                </div>
                <!-- /.card -->
              </div>
              <!-- /.col -->
            </div>
            <!-- /.row -->
          </div>
          <!-- /.container-fluid -->
        </section>
        <!-- /.content -->
      </div>
      <!-- Control Sidebar -->
      <aside class="control-sidebar control-sidebar-dark">
        <!-- Control sidebar content goes here -->
      </aside>

{% endblock %}

{% block footer_js %}
<!-- jQuery -->
<script src="/static/plugins/jquery/jquery.min.js"></script>
<!-- Bootstrap 4 -->
<script src="/static/plugins/bootstrap/js/bootstrap.bundle.min.js"></script>
<!-- DataTables  & Plugins -->
<script src="/static/plugins/datatables/jquery.dataTables.min.js"></script>
<script src="/static/plugins/datatables-bs4/js/dataTables.bootstrap4.min.js"></script>
<script src="/static/plugins/datatables-responsive/js/dataTables.responsive.min.js"></script>
<script src="/static/plugins/datatables-responsive/js/responsive.bootstrap4.min.js"></script>
<script src="/static/plugins/datatables-buttons/js/dataTables.buttons.min.js"></script>
<script src="/static/plugins/datatables-buttons/js/buttons.bootstrap4.min.js"></script>
<script src="/static/plugins/jszip/jszip.min.js"></script>
<script src="/static/plugins/pdfmake/pdfmake.min.js"></script>
<script src="/static/plugins/pdfmake/vfs_fonts.js"></script>
<script src="/static/plugins/jszip/jszip.js"></script>
<script src="/static/plugins/datatables-buttons/js/buttons.html5.min.js"></script>
<script src="/static/plugins/datatables-buttons/js/buttons.print.min.js"></script>
<script src="/static/plugins/datatables-buttons/js/buttons.colVis.min.js"></script>
<script src="/static/plugins/daterangepicker/daterangepicker.js"></script>
    <!-- Select2 -->
<script src="/static/plugins/select2/js/select2.full.min.js"></script>

<!-- AdminLTE App -->
{#<script src="/static/dist/js/adminlte.min.js"></script>#}
<script src="/static/js/jquery.form.js"></script>
<script src="/static/js/bootstrap-growl.js"></script>
<script>
    //重置按钮
    $("#reset").on('click', function () {
        document.getElementById("industry_add").value='';
        document.getElementById("industry_delete").value='';
    });

    // 提交数据
    $("#configurationForm").ajaxForm({
        type: "post",
        url: "/configuration/conf/save/",    //提交到的url
        success: function (data) {
            if (data.success) {
                $.growlService("保存成功", {type: "success"})
                setTimeout(() => {
                  window.location.reload()
                }, 1000)
            }
            else {
                $.growlService(data.error_message, {type: "danger"})
            }
        }
    });
</script>
{% endblock %}
